package org.akomantoso.core.data;

import java.io.IOException;

import org.akomantoso.core.data.group.DocRef;
import org.akomantoso.core.io.Output;

/**
 * The element hasAttachment is a metadata reference to the Akoma Ntoso URI of an attachment of this document.
 * 
 * <pre>
 * 	<xsd:element name="hasAttachment" type="referenceType">
 * 		<xsd:complexType>
 * 			<xsd:complexContent>
 * 				<xsd:extension base="referenceType">
 * 					<xsd:attribute name="type" type="xsd:string"/>
 * 				 </xsd:extension>
 * 			</xsd:complexContent>
 * 		</xsd:complexType>
 * 	</xsd:element>
 * </pre>
 * 
 * @author <a href="mailto:jacques.militello@gmail.com">Jacques Militello</a>
 * 
 * @since http://www.akomantoso.org/1.0
 */
public final class HasAttachment extends ReferenceType implements DocRef {

	public static final String ELEMENT = "hasAttachment";

	public static final String ATTRIBUTE_TYPE = "type";

	private String _type;

	public String getType() {
		return _type;
	}

	public void setType(String type) {
		_type = type;
	}

	/**
	 * @see org.akomantoso.core.data.ReferenceType#writeExternal(org.akomantoso.core.io.Output)
	 */
	@Override
	public <T extends Output> void writeExternal(T out) throws IOException {
		out.writeStart(ELEMENT);
		if (_type != null) {
			out.writeAttribute(ATTRIBUTE_TYPE, _type);
		}
		super.writeExternal(out);
		out.writeEnd();
	}

}